<template>
    <div class='mainDivClass'>
     <div class='topBox'>
      <div class='leftBox'>
        <div class='PictureClass'>
          <img src='../../Home/Components/image/wangfugan.png' height='150' />
        </div>
        <div class='TitleClass'>
          <span>副线往复杆</span>
        </div>
      </div>
      <div class='rightBox'>
        <div style="height: 25%;width: 100%; display: flex;margin-top: 5%">
          <div class="ValueTitleClass">副线往复杆手动模式:</div>
          <div class="ValueClass">{{dataList_FX.Secondcontactpole_Manual_Mode | Maincontactpole_Manual_Mode}}</div>
          <div class="ValueTitleClass">副线往复杆模式给定:</div>
          <div class="ValueClass">{{dataList_FX.Secondcontactpole_Manual_ModeSign | Maincontactpole_Manual_ModeSign}}</div>
        </div>
        <div style="height: 25%;width: 100%; display: flex;">
          <div class="ValueTitleClass">副线往复杆使能给定:</div>
          <div class="ValueClass">{{dataList_FX.Secondcontactpole_Manual_EnableSign | Maincontactpole_Manual_EnableSign}}</div>
          <div class="ValueTitleClass">副线往复杆使能状态:</div>
          <div class="ValueClass">{{dataList_FX.Secondcontactpole_Manual_Enable | Maincontactpole_Manual_Enable}}</div>
        </div>
        <div style="height: 25%;width: 100%; display: flex;">
          <div class="ValueTitleClass">副线往复杆故障代码:</div>
          <div class="ValueClass">{{dataList_FX.Secondcontactpole3_Servo_Errorcode }}</div>
          <div class="ValueTitleClass">副线往复杆回零触发:</div>
          <div class="ValueClass">{{dataList_FX.Secondcontactpole3_Trig_Rzero }}</div>
        </div>
      </div>
    </div>
      <div class='bottomBox'>
        <div class="tableDiv">
          <table class="tableClass">
            <tr class="TrClass">
              <td class="TDClassTitle">副线往复杆3/自动定位脉冲</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Auto_Pulse}}</td>
              <td class="TDClassTitle">副线往复杆3/自动定位速度r/min</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Auto_Speed}}</td>
              <td class="TDClassTitle">副线往复杆3/轴使能</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Axis_Enable}}</td>
              <td class="TDClassTitle">副线往复杆3/轴停止</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Axis_Stop}}</td>
            </tr>
            <tr class="TrClass">
              <td class="TDClassTitle">副线往复杆3/故障清除</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Clean_Alarm}}</td>
              <td class="TDClassTitle">副线往复杆3/控制模式</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Control_Mode}}</td>
              <td class="TDClassTitle">副线往复杆3/正向点动</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Inche_Positive}}</td>
              <td class="TDClassTitle">副线往复杆3/反向点动</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Inche_Reverse}}</td>
            </tr>
            <tr class="TrClass">
              <td class="TDClassTitle">副线往复杆3/点动速度r/min</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Inche_Speed}}</td>
              <td class="TDClassTitle">副线往复杆3/手动定位位置mm</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Manual_Position}}</td>
              <td class="TDClassTitle">副线往复杆3/手动定位速度mm/s</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Manual_Speed}}</td>
              <td class="TDClassTitle">副线往复杆3/当前负载率%</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Nloadrate}}</td>
            </tr>
            <tr class="TrClass">
              <td class="TDClassTitle">副线往复杆3/当前位置pulse</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Nposition}}</td>
              <td class="TDClassTitle">副线往复杆3/当前速度r/min</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Nspeed}}</td>
              <td class="TDClassTitle">副线往复杆3/当前扭矩N.m</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Ntorque}}</td>
              <td class="TDClassTitle">副线往复杆3/位置到达标志</td>
              <td class="TDClassVal">{{dataList_FX. Secondcontactpole3_Position_Ok}}</td>
            </tr>
            <tr class="TrClass">
              <td class="TDClassTitle">副线往复杆3/伺服准备好</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Ready_Servo}}</td>
              <td class="TDClassTitle">副线往复杆3/抱闸信号解除标志</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Relieve_Bandbrake}}</td>
              <td class="TDClassTitle">副线往复杆3/回零完成标志</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Rzero_Ok }}</td>
              <td class="TDClassTitle">副线往复杆3/驱动器故障代码</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Servo_Errorcode}}</td>
            </tr>
            <tr class="TrClass">
              <td class="TDClassTitle">副线往复杆3/速度到达标志</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Speed_Ok}}</td>
              <td class="TDClassTitle">副线往复杆3/目标位置pulse</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Target_Position}}</td>
              <td class="TDClassTitle">副线往复杆3/目标速度r/min</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Target_Speed}}</td>
              <td class="TDClassTitle">副线往复杆3/定位触发</td>
              <td class="TDClassVal">{{dataList_FX.Secondcontactpole3_Trig_Location}}</td>
            </tr>
          </table>
        </div>

      </div>
    </div>
</template>

<script>
import { GetDataFX } from "@/api";
    export default {
      name: 'DetailViews_FuXIan',
      data() {
        return{
          dataList_FX:{
            "Secondcontactpole3_Auto_Pulse":"0", //副线往复杆3/自动定位脉冲
            "Secondcontactpole3_Auto_Speed":"1005", //副线往复杆3/自动定位速度r/min
            "Secondcontactpole3_Axis_Enable":"0", //副线往复杆3/轴使能
            "Secondcontactpole3_Axis_Stop":"1", //副线往复杆3/轴停止
            "Secondcontactpole3_Clean_Alarm":"0", //副线往复杆3/故障清除
            "Secondcontactpole3_Control_Mode":"", //副线往复杆3/控制模式
            "Secondcontactpole3_Inche_Positive":"0", //副线往复杆3/正向点动
            "Secondcontactpole3_Inche_Reverse":"0", //副线往复杆3/反向点动
            "Secondcontactpole3_Inche_Speed":"50", //副线往复杆3/点动速度r/min
            "Secondcontactpole3_Manual_Position":"0", //副线往复杆3/手动定位位置mm
            "Secondcontactpole3_Manual_Speed":"200", //副线往复杆3/手动定位速度mm/s
            "Secondcontactpole3_Nloadrate":"0", //副线往复杆3/当前负载率%
            "Secondcontactpole3_Nposition":"-11", //副线往复杆3/当前位置pulse
            "Secondcontactpole3_Nspeed":"0", //副线往复杆3/当前速度r/min
            "Secondcontactpole3_Ntorque":"0", //副线往复杆3/当前扭矩N.m
            "Secondcontactpole3_Position_Ok":"1", //副线往复杆3/位置到达标志
            "Secondcontactpole3_Ready_Servo":"1", //副线往复杆3/伺服准备好
            "Secondcontactpole3_Relieve_Bandbrake":"0", //副线往复杆3/抱闸信号解除标志
            "Secondcontactpole3_Rzero_Ok":"0", //副线往复杆3/回零完成标志
            "Secondcontactpole3_Servo_Errorcode":"256", //副线往复杆3/驱动器故障代码
            "Secondcontactpole3_Speed_Ok":"1",//副线往复杆3/速度到达标志
            "Secondcontactpole3_Target_Position":"0", //副线往复杆3/目标位置pulse
            "Secondcontactpole3_Target_Speed":"1005", //副线往复杆3/目标速度r/min
            "Secondcontactpole3_Trig_Location":"0", //副线往复杆3/定位触发
            "Secondcontactpole3_Trig_Rzero":"0", //副线往复杆3/回零触发
            'Secondcontactpole_Manual_Enable': '0', //副线往复杆手动定位/使能状态 0: 无使能1:使能
            'Secondcontactpole_Manual_EnableSign': '0',//副线往复杆手动定位/使能已给定  0: 使能未给定1:使能已给定
            'Secondcontactpole_Manual_Mode': '1',// 副线往复杆手动定位/手动模式  0: 非手动模式1:手动模式
            'Secondcontactpole_Manual_ModeSign': '0',//副线往复杆手动定位/模式已给定 0:  模式未给定1:模式已给定
            'Secondcontactpole_Manual_Nposition': '0',//副线往复杆手动定位/当前位置mm
            'Secondcontactpole_Manual_Nspeed': '0',//副线往复杆手动定位/当前速度rpm
            'Secondcontactpole_Manual_Sposition': '0',//副线往复杆手动定位/位置设定mm
            'Secondcontactpole_Manual_Sspeed': '500',//副线往复杆手动定位/速度设定rpm
            'Secondcontactpole_Manual_StartSign': '0'//副线往复杆手动定位/开始已给定
          }
        }
      },
      mounted() {
        this.getData()
        this.timer = setInterval(() => {
          this.getData();
        }, window.config.HomeReloadTime);
      },
      methods: {
        getData() {
          GetDataFX().then(res => {
            var DataStr = res.data.split('<html><title>数据推送</title><body><p style="background-color:green; width:500px; word-break:break-all;white-space:normal;word-wrap:break-word;">')[1].split('</p></body></html>\r\n')[0]
            var DataJson = JSON.parse(DataStr)
            this.dataList_FX = DataJson.params
          });
        },
      },
      filters: {
        Maincontactpole_Manual_Mode: function (value) {
          if (value==='0') {
            return '非手动模式'
          } else {
            return '手动模式'
          }
        },
        Maincontactpole_Manual_ModeSign: function (value) {
          if (value==='0') {
            return '模式未给定'
          } else {
            return '模式已给定'
          }
        },
        Maincontactpole_Manual_EnableSign: function (value) {
          if (value==='0') {
            return '使能未给定'
          } else if(value==='1') {
            return '使能已给定'
          }
        },
        Maincontactpole_Manual_Enable: function (value) {
          if (value==='0') {
            return '无使能'
          } else if(value==='1') {
            return '使能'
          }
        },
        //秒数转化为时分秒
        formatSeconds: function(value) {
          var secondTime = parseInt(value);// 秒
          var minuteTime = 0;// 分
          var hourTime = 0;// 小时
          if(secondTime > 60) {//如果秒数大于60，将秒数转换成整数
            //获取分钟，除以60取整数，得到整数分钟
            minuteTime = parseInt(secondTime / 60);
            //获取秒数，秒数取余，得到整数秒数
            secondTime = parseInt(secondTime % 60);
            //如果分钟大于60，将分钟转换成小时
            if(minuteTime > 60) {
              //获取小时，获取分钟除以60，得到整数小时
              hourTime = parseInt(minuteTime / 60);
              //获取小时后取余的分，获取分钟除以60取余的分
              minuteTime = parseInt(minuteTime % 60);
            }
          }
          if((secondTime+"").length===1){
            secondTime = "0" + secondTime
          }
          var result = "" + secondTime + "";

          if(minuteTime > 0) {
            if((minuteTime+"").length===1){
              minuteTime = "0" + minuteTime
            }
            result = "" + parseInt(minuteTime) + ":" + result;
          }
          if(hourTime > 0) {
            if((hourTime+"").length===1){
              hourTime = "0" + hourTime
            }
            result = "" + hourTime + ":" + result;
          }
          console.log('result',result);
          return result;
        }
      }
    }
</script>

<style lang='scss' scoped>
.mainDivClass{
  height: 100%;
  width: 100%;
  .topBox{
    height: 30%;
    width: 96%;
    margin-left: 2%;
    margin-top: 2%;
    border: 1px solid black;
    .leftBox{
      height: 100%;
      width: 30%;
      float: left;
      border: 1px solid black;
      .PictureClass{
        height: 50%;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
      }
      .TitleClass{
        height: 50%;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 40px;
        font-family: PingFangSC-Semibold, PingFang SC;
        font-weight: 600;
        color: #17FFFF;
      }
    }
    .rightBox{
      height: 100%;
      width: 70%;
      float: left;
      border: 1px solid black;
      .ValueTitleClass{
        width: 25%;
        height: 30%;
        display: flex;
        justify-content: left;
        margin-left: 2%;
        align-items: center;
        font-size: 30px;
        font-family: PingFangSC-Semibold, PingFang SC;
        font-weight: 600;
        color: #BBE0F8;
        float: left;
      }
      .ValueClass{
        float: left;
        width: 25%;
        height: 30%;
        display: flex;
        justify-content: left;
        align-items: center;
        font-size: 40px;
        font-family: PingFangSC-Semibold, PingFang SC;
        font-weight: 600;
        color: #17FFFF;
      }
    }
  }
  .bottomBox{
    height: 58%;
    width: 96%;
    margin-left: 2%;
    border: 1px solid black;
    .tableDiv{
      height: 100%;
      width: 100%;
      .tableClass{
        width: 100%;
        border: 1px solid white;
        .TrClass{
          height: 45px;
          line-height: 45px;
          width: 100%;
          margin-top: 5%;
          border: 1px solid white;
          .TDClassTitle{
            height: 100%;
            border: 1px solid white;
            width: 20%;
            text-align: center;
            font-size: 20px;
            font-family: PingFangSC-Semibold, PingFang SC;
            font-weight: 600;
            color: #BBE0F8;
          }
          .TDClassVal{
            text-align: center;
            height: 100%;
            border: 1px solid white;
            width: 3%;
            font-size: 20px;
            font-family: PingFangSC-Semibold, PingFang SC;
            font-weight: 600;
            color: #17FFFF;
          }
        }
      }
    }
  }
}
</style>
